from distutils.core import setup, Extension
from distutils.command import install_headers
from os import environ, getcwd
from os.path import dirname, abspath, join

from numpy.distutils.misc_util import get_numpy_include_dirs

vector_sources = ['physics/vector/vector.i']
function_sources = ['physics/function/function.i']

vector_hpp_include = '{0}/include'.format(environ['HOME'])

with open('physics/test.py', 'w') as fptest:
    fptest.write("test_dir = '{0}'\n".format(join(abspath(getcwd()), 'test')))
    fptest.write("event_sample = '{0}'\n".format(join(abspath(getcwd()), 'test', 'event_sample.gamp')))


setup(name="physics",
      version="0.8.0",
      description="Python physics stuff",
      author="Craig Bookwalter",
      author_email="craigb@jlab.org",
      url="https://jlabsvn.jlab.org/svnroot/clas/users/craigb/python-physics",
      packages="physics physics.vector physics.vector.array physics.const physics.function".split(),
      ext_modules=[Extension('physics.vector._vector', 
                             vector_sources,
                             include_dirs=[vector_hpp_include],
                             language='c++',
                             swig_opts=['-c++', 
                                        "-I{0}".format(vector_hpp_include),
                                        ]),
                   Extension('physics.vector.array._array',
                             ['physics/vector/array/src/array.c'],
                             include_dirs=get_numpy_include_dirs(),
                             ),
                   Extension('physics.function._function', 
                             function_sources,
                             include_dirs=[dirname(vector_sources[0]), 
                                           dirname(function_sources[0]),
                                           vector_hpp_include,
                                           ],
                             language='c++',
                             swig_opts=['-c++',
                                        "-I{0}".format(vector_hpp_include),
                                        ])
                   ]
      )



